﻿ // Urls to access the WCF Rest service methods
var GetListings = "http://localhost:4305/Service/GetListings";
var GetListing = "http://localhost:4305/Service/GetListing";
var GetAddresses = "http://localhost:4305/Service/GetAddresses";
var GetAddress = "http://localhost:4305/Service/GetAddress";
var GetUtilies = "http://localhost:4305/Service/GetUtilies";
var GetUtility = "http://localhost:4305/Service/GetUtility";
 
    var nextStudentID = 1;
    var jDepartment = null;
    var jPendingStudent = null;

    function makeTable(jObject) {
        var jArrayObject = jObject
        if (jObject.constructor != Array) {
            jArrayObject = new Array();
            jArrayObject[0] = jObject;
        }

        var table = document.createElement("table");
        table.setAttribute('cellpadding', '4px');
        table.setAttribute('rules', 'all');
        var tboby = document.createElement("tbody");

        var trh = document.createElement('tr');
        for (var key in jArrayObject[0]) {
            var th = document.createElement('th');
            th.appendChild(document.createTextNode(key));
            trh.appendChild(th);
        }
        tboby.appendChild(trh);

        $.each(jArrayObject, function (i, v) {
            var tr = document.createElement('tr');
            for (var key in v) {
                var td = document.createElement('td');
                td.appendChild(document.createTextNode(v[key]));
                tr.appendChild(td);
            }
            tboby.appendChild(tr);
        });

        table.appendChild(tboby)

        return table;
    }